/**
 * @Author：ming
 * @Date：2023/10/27 12:26 AM
 * @Filename：LC1
 */

import java.util.HashMap;

/**
 * @author ming
 */
public class LC1 {
    public int[] twoSum(int[] nums, int target) {
        int[] index = new int[]{-1,-1};
        int len = nums.length;
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < len; i++) {
            if(map.containsKey(nums[i])){
                index[0] = map.get(nums[i]);
                index[1]= i;
                break;
            }else {
                map.put(target-nums[i],i);
            }
        }
        map.clear();
        return index;
    }
}
